class SRStatList extends GUIVertList;

// Display
var	texture	InfoBackground;

// State
var	localized array<string>			ProgressName;
var	array<string>				StatProgress;
var	array<byte>				DisplayFormat; // 0 - value, 1 - time

function bool PreDraw(Canvas Canvas)
{
	return false;
}

function InitList( ClientPerkRepLink L )
{
	local SRCustomProgress P;
	local int i;

	for( P=L.CustomLink; P!=None; P=P.NextLink )
		++i;

	ItemCount = Default.ProgressName.Length+i;
	ProgressName.Length = ItemCount;
	StatProgress.Length = ItemCount;

	i = Default.ProgressName.Length;
	for( P=L.CustomLink; P!=None; P=P.NextLink )
	{
		ProgressName[i] = P.ProgressName;
		StatProgress[i] = P.GetDisplayString();
		++i;
	}

	// Update the ItemCount and select the first item
	SetIndex(0);

	StatProgress[0] = string(L.RDamageHealedStat);
	StatProgress[1] = string(L.RMassHealPoints);
	StatProgress[2] = string(L.RCalmedPounds);

	StatProgress[3] = string(L.RWeldingPointsStat);
	StatProgress[4] = string(L.RShotgunDamageStat);
	StatProgress[5] = string(L.RspHeavyMonsterPoints);

	StatProgress[6] = string(L.RHeadshotKillsStat);
	StatProgress[7] = string(L.RHeadShotHuskPoints);
	StatProgress[8] = string(L.RssHeavyMonsterPoints);
	StatProgress[9] = string(L.RHeadShotMPKillsStat);

	StatProgress[10] = string(L.RBullpupDamageStat);
	StatProgress[11] = string(L.RStalkerKillsStat);
	StatProgress[12] = string(L.RcmHeavyMonsterPoints);

	StatProgress[13] = string(L.RMeleeDamageStat);
	StatProgress[14] = string(L.RMeleeGoreFastKillsStat);
	StatProgress[15] = string(L.RbHeavyMonsterPoints);

	StatProgress[16] = string(L.RFlameThrowerDamageStat);
	StatProgress[17] = string(L.RBurnedCrawlersStat);
	StatProgress[18] = string(L.RfHeavyMonsterPoints);

	StatProgress[19] = string(L.RExplosivesDamageStat);
	StatProgress[20] = string(L.RPipeBombDamageStat);
	StatProgress[21] = string(L.RdmHeavyMonsterPoints);

	StatProgress[22] = string(L.RSoleSurvivorWavesStat);
	StatProgress[23] = string(L.RKillsStat);
	StatProgress[24] = string(L.TotalPlayTime);
	StatProgress[25] = string(L.WinsCount);
	StatProgress[26] = string(L.LostsCount);

	for( i=0; i<DisplayFormat.Length; ++i )
		if( DisplayFormat[i]==1 )
			StatProgress[i] = GetTimeText(int(StatProgress[i]));

	if ( bNotify )
	{
		CheckLinkedObjects(Self);
	}

	if ( MyScrollBar != none )
	{
		MyScrollBar.AlignThumb();
	}
}

final function string GetTimeText( int V )
{
	local int Hours, Minutes;

	Minutes = V / 60;
	Hours   = Minutes / 60;
	V -= (Minutes * 60);
	Minutes -= (Hours * 60);

	return Eval(Hours<10,"0"$Hours,string(Hours))$":"$Eval(Minutes<10,"0"$Minutes,string(Minutes))$":"$Eval(V<10,"0"$V,string(V));
}
function DrawStat(Canvas Canvas, int CurIndex, float X, float Y, float Width, float Height, bool bSelected, bool bPending)
{
	local float TempX, TempY;
	local float TempWidth, TempHeight;

	// Offset for the Background
	TempX = X;
	TempY = Y;

	// Initialize the Canvas
	Canvas.Style = 1;
	Canvas.Font = class'ROHUD'.Static.GetSmallMenuFont(Canvas);
	Canvas.SetDrawColor(255, 255, 255, 255);

	// Draw Item Background
	Canvas.SetPos(TempX, TempY);
	Canvas.DrawTileStretched(InfoBackground, Width, Height);

	// Select Text Color
	Canvas.SetDrawColor(0, 0, 0, 255);

	// Draw progress type.
	Canvas.TextSize(ProgressName[CurIndex],TempWidth,TempHeight);
	TempX += Width*0.1f;
	TempY += (Height-TempHeight) * 0.5f;
	Canvas.SetPos(TempX, TempY);
	Canvas.DrawText(ProgressName[CurIndex]$":");

	// Draw current progress.
	Canvas.TextSize(StatProgress[CurIndex],TempWidth,TempHeight);
	Canvas.SetPos(X + Width*0.88f - TempWidth, TempY);
	Canvas.DrawText(StatProgress[CurIndex]);
}

function float PerkHeight(Canvas c)
{
	return (MenuOwner.ActualHeight() / 14.0) - 1.0;
}

defaultproperties
{
     InfoBackground=Texture'KF_InterfaceArt_tex.Menu.Item_box_bar'
     ProgressName(0)="Healed damage"
     ProgressName(1)="Damage healed with medic nade and M56"
     ProgressName(2)="Pounds calmed with acid gun"
     ProgressName(3)="Welded hitpoints"
     ProgressName(4)="Shotgun damage"
     ProgressName(5)="Support big monster points"
     ProgressName(6)="Headshot kills"
     ProgressName(7)="Husks and Incinerators killed with headshots"
     ProgressName(8)="Sharpshooter big monster points"
     ProgressName(9)="MP killed with headshots"
     ProgressName(10)="Damage done with commando weapons"
     ProgressName(11)="Stalkers killed with commando weapons"
     ProgressName(12)="Commando big monster points"
     ProgressName(13)="Melee damage"
     ProgressName(14)="Gorefasts killed with melee weapons"
     ProgressName(15)="Berserker big monster points"
     ProgressName(16)="Flame thrower damage"
     ProgressName(17)="Crawlers killed with fire weapons"
     ProgressName(18)="Firebug big monster points"
     ProgressName(19)="Explosives damage count"
     ProgressName(20)="Damage done with pipeboms"
     ProgressName(21)="Demolition big monster points"
     ProgressName(22)="Sole survivor waves count"
     ProgressName(23)="Total kills"
     ProgressName(24)="Total playtime"
     ProgressName(25)="Won games"
     ProgressName(26)="Lost games"
     DisplayFormat(24)=1
     GetItemHeight=SRStatList.PerkHeight
     ItemCount=27
     OnDrawItem=SRStatList.DrawStat
     FontScale=FNS_Medium
     OnPreDraw=SRStatList.PreDraw
}
